package com.ste.client.service;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.logging.Logger;

import com.ste.client.WriteServer;

public class ClientMessages {
	private static final int QUEUE_CAPACITY = 10;
	private static Logger log = Logger.getLogger(WriteServer.class.getName());
	BlockingQueue<String> messageQueue = new ArrayBlockingQueue<String>(QUEUE_CAPACITY, true);

	public void addMessage(String message) {
		try {
			messageQueue.put(message);
			log.info("added " + message );
		} catch (InterruptedException e) {
		}
	}

	public String getMessage() throws InterruptedException {
		String mes = messageQueue.take();
		log.info("sent " + mes);
		return mes;
	}

}
